package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.config.shiro.MallToken;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author stone
 * @date 2022/06/07 01:06
 */
@RestController
@RequestMapping("wx/auth")
public class WxAuthController {

    @RequestMapping("login")
    public BaseRespVo login(@RequestBody Map map) {
        String username = (String) map.get("username");
        String password = (String) map.get("password");

        Subject subject = SecurityUtils.getSubject();
        //subject.login(new UsernamePasswordToken(username, password));
        subject.login(new MallToken(username, password,"wx"));

        return BaseRespVo.ok(null);
    }
}
